<template>
<div class="discover">
    <Header/>
<div class="nav">
    <router-link  @click.native="tui(index)" v-for="(value,index) in nav" :key="index" to="">
        <span :class="{Font:(index==Num)||(value.co!==''&&Num==dynamic.length-1)}">{{value.name}}
        <span v-show="value.hot!==''">Hot</span>
        </span>
    </router-link>
</div>
    <div v-show="Num==0||Num==dynamic.length-1"  class="nav_b">
        <div>发现精彩旅拍</div>
        <div>
            <router-link :class="{Color1:true,Color2:Num==0}" to="" @click.native="New(0)" >综合</router-link>
            <router-link :class="{Color1:true,Color2:Num==dynamic.length-1}" to="" @click.native="New(1)">最新</router-link>
        </div>
    </div>
    <div class="content" v-for="(item,index) in dynamic" :key="index" v-show="index==Num">
        <div v-for="(value,index) in item" class="cont" >
            <div><img :src="value.img" alt=""></div>
            <div>
                <i class="iconfont icon-dingwei"></i>
                <span>{{value.local}}</span>
            </div>
            <div>{{value.text}}</div>
            <div>
                <div>
                    <div>
                        <i class="iconfont icon-VIP"></i>
                        <img :src="value.tou" alt="">
                    </div>
                    <div>
                        <span>{{value.name}}</span>
                        <span>
                                <span>{{value.title}}</span>
                        </span>
                    </div>
                </div>
                <div>
                    <i class="iconfont icon-dianzan"></i>
                    <span>{{value.Thumb}}</span>
                </div>
            </div>
        </div>
    </div>
    <!--点击添加自己的动态-->
    <router-link to="" class="dong">+</router-link>
    <Footer/>
</div>
</template>
<style scoped lang="less">
    //  初始化
    *{
        margin: 0;
        padding: 0;
        box-sizing: border-box;
        list-style-type: none;
        text-decoration: none;
    }


    //  导航
    .nav{
        width: 100%;
        display: flex;
        overflow: auto;
        height: 1.599rem;
        align-items: center;
        margin-top: 6.263rem;
        >a{
            flex-shrink: 0;
            margin-right: 0.853rem;
            font-size: 0.426rem;
            color: #000;
            display: flex;
            align-items: center;
            //  Hot
            >span {
                position: relative;
                > span {
                    top: -0.346rem;
                    position: absolute;
                    right: -0.533rem;
                    color: #fff;
                    background-color: darkorange;
                    width: 0.959rem;
                    height: 0.373rem;
                    font-size: 0.32rem;
                    border-bottom-right-radius: 0.48rem;
                    border-top-right-radius: 0.48rem;
                    border-top-left-radius: 0.48rem;
                }
            }

        }
    }
    .Font{
        font-size: 0.48rem;
        border-bottom: 0.107rem solid #00CC99;
        padding: 0.053rem 0.027rem;
        border-radius: 0.053rem;
    }
    .Font1{
        font-size: 0.48rem;
        border-bottom: 0.107rem solid #00CC99;
        padding: 0.053rem 0.027rem;
        border-radius: 0.053rem;
    }
    .Top{
        top: -40%;
    }
    .nav_b{
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin: 0 0.213rem;
        font-size: 0.373rem;
        color: rgba(0,0,0,0.7);
        >div:nth-child(2){
            width: 30%;
            height: 100%;
            display: flex;
            align-items: center;
            >a{
                width: 50%;
            }
            >a:nth-child(1){
                border-right: 0.027rem solid #aaa;

            }
        }

    }
.Color1{
    color: rgba(0,0,0,0.7);
 }
.Color2{
    color: #00CC99;
    font-weight: bold;
}
    //  底部动态
    .content{
        min-height: 17.777rem;
        display: flex;
        flex-flow: wrap;
        justify-content: space-around;
        margin-bottom: 1.866rem;
        //  单个动态
        >.cont{
            width: 48%;
            min-height: 8.795rem;
            display: flex;
            flex-flow: column;
            justify-content: space-around;
            margin-top: 0.267rem;
            /* 顶部图片 */
            >div:nth-child(1){
                width: 100%;
                height: 200px;
                >img{
                    width: 100%;
                    height: 100%;
                    border-radius: 0.267rem;
                }
            }
            //  定位
            >div:nth-child(2){
                width: 1.466rem;
                height: 0.666rem;
                border-radius: 0.666rem;
                display: flex;
                justify-content: center;
                align-items: center;
                background-color: #ddd;
                color: rgba(0,0,0,.6);
            }
            //  个人描述
            >div:nth-child(3){
                width: 95%;
                font-size: 0.373rem;
                font-weight: bold;
                color: #000;
                text-align: left;
                overflow: hidden;
                text-overflow: ellipsis;
                display: -webkit-box;
                -webkit-line-clamp:2;
                -webkit-box-orient: vertical;
            }
            //  作者
            >div:nth-child(4){
                display: flex;
                justify-content: space-between;
                >div:nth-child(1){
                    display: flex;
                    width: 74%;
                    >div:nth-child(1){
                        position: relative;
                        display: flex;
                        margin-right: 0.267rem;
                        //  vip标识
                        >i{
                            font-size: 0.4rem;
                            position: absolute;
                            bottom: 0;
                            left: 0.533rem;
                            color: #ff7c05;
                        }
                        //  头像
                        >img{
                            width: 0.8rem;
                            height: 0.8rem;
                            border-radius: 50%;
                        }
                    }
                    //  作者名
                    >div:nth-child(2){
                        display: flex;
                        flex-flow: column;
                        >span{
                            font-size: 0.32rem;
                            text-align: left;
                            overflow: hidden;
                            text-overflow: ellipsis;
                            display: -webkit-box;
                            -webkit-line-clamp:1;
                            -webkit-box-orient: vertical;
                        }
                        >span:nth-child(1){
                            color: rgba(0,0,0,.6);
                        }
                        //  头衔
                        >span:nth-child(2){
                            >span{
                                padding: 0.08rem;
                                background-color: #fff99a;
                                color: #ffbc27;
                                border-bottom-right-radius: 0.24rem;
                                border-top-left-radius: 0.24rem;
                            }
                        }
                    }
                }
                >div:nth-child(2){
                    display: flex;
                    width: 1.199rem;
                    justify-content: space-between;
                    align-items: flex-end;
                    >i{
                        /*color: red;*/
                    }
                    >span{
                        margin-bottom: 5%;
                    }
                }
            }
        }
    }
    //  添加自己的动态
    .dong{
        position: fixed;
        right: 0.8rem;
        bottom: 2.132rem;
        width: 1.466rem;
        height: 1.466rem;
        border-radius: 50%;
        background-color: #00CC99;
        color: #fff;
        font-size: 1.199rem;
        line-height: 1.466rem;
    }
</style>
<script>
    //  引入公共头部尾部组件
    import Header from '@/components/header.vue'
    import Footer from '@/components/footer.vue'
    //  顶部轮播图
    export default {
        data(){
            return {
                //  导航
                nav:[],
                //  控制切换相应导航动态
                Num:0,
                isC:true,
                //  发现
                dynamic:[],
            }
        },
        methods:{
            //  发现  点击切换不同
            tui(index){
                this.Num=index;
            },
            //  综合 及 最新  (推荐)
            New(index){
                if (index==0){
                    this.Num=0;
                } else if (index==1) {
                    this.Num=this.dynamic.length-index;
                }

            }
        },
        components: {
            Header,
            Footer
        },
        mounted() {
            this.Num=this.$store.state.Num;
            this.$axios.get('http://118.178.85.166:3000/discover').then((data)=>{
                //  全部数据
                let Data=data.data[0];
                //  导航
                this.nav=JSON.parse(Data.nav);
                //  推荐（最新）
                this.dynamic.push(JSON.parse(Data.dynamic).recommend);
                //  周边
                this.dynamic.push(JSON.parse(Data.dynamic).rim);
                //  绝美赏秋地
                this.dynamic.push(JSON.parse(Data.dynamic).reward);
                //  探店咖啡馆
                this.dynamic.push(JSON.parse(Data.dynamic).coffee);
                //  视频灵感
                this.dynamic.push(JSON.parse(Data.dynamic).video);
                //  美食寻味之旅
                this.dynamic.push(JSON.parse(Data.dynamic).cate);
                //  达人带你住
                this.dynamic.push(JSON.parse(Data.dynamic).intelligent);
                //  亲子时光
                this.dynamic.push(JSON.parse(Data.dynamic).offspring);
                //  酷玩好去处
                this.dynamic.push(JSON.parse(Data.dynamic).Coldplay);
                //  旅行愿望清单
                this.dynamic.push(JSON.parse(Data.dynamic).wish);
                //  最新
                this.dynamic.push(JSON.parse(Data.dynamic).newest);
            }).catch((err)=>{
                console.log('这是discover.vue中的错误:'+err);
            });
        }
    }

</script>
